import scheduled,threading,tkinter as tk,datetime,threading,time,pdb
#scheduled.time.sleep=lambda *args,**kwargs:pdb.set_trace()
def close(ev):
    ev.widget.destroy()
def blackScreen(exittime):
    win=tk.Tk()
    win.configure(background='Black')
    win.attributes("-topmost",True)
    win.attributes("-fullscreen",True)
    win.bind("<Button-3>",close)
    win.after(exittime*1000,win.destroy)
    win.mainloop()
    return win
def resumeScreen(win):
    #win.destroy()
    pass
def halt(a):
    import os
    os.system("shutdown -p")

t=scheduled.TimeConstructor()
class Lessons:
    #Morning
    First=t[7:50,8:30].setAction(blackScreen)
    Second=t[8:40,9:20].setAction(blackScreen)
    Third=t[9:30,10:10].setAction(blackScreen)
    Exercise=t[10:13,10:25].setAction(blackScreen)
    Forth=t[10:30,11:10].setAction(blackScreen)
    Fifth=t[11:15,11:55].setAction(blackScreen)
    #Afternoon
    AfternoonFirst=t[14:00,14:40].setAction(blackScreen)
    AfternoonSecond=t[14:50,15:30].setAction(blackScreen)
    AfternoonThird=t[15:40,16:20].setAction(blackScreen)
    AfternoonForth=t[16:30,17:10].setAction(blackScreen)

noonhalt=t[11:56,12:00].setAction(halt)
afternoonhalt=t[17:11,17:20].setAction(halt)

OFFTIMES=[
            #Monday
            [Lessons.AfternoonSecond,Lessons.AfternoonThird],
            #Tuesday
            [Lessons.Exercise,Lessons.AfternoonThird,Lessons.AfternoonForth],
            #Wednesday
            [Lessons.First,Lessons.Exercise,Lessons.AfternoonThird,Lessons.AfternoonForth,],
            #Thursday
            [Lessons.Exercise,Lessons.AfternoonThird,Lessons.AfternoonForth,],
            #Friday
            [Lessons.Exercise,Lessons.Fifth,Lessons.AfternoonThird,Lessons.AfternoonForth,],
            #Saturday
            [Lessons.Exercise,Lessons.AfternoonFirst,Lessons.AfternoonSecond,],
            #Sunday
            [],
        ]

Day=datetime.datetime.today().weekday()
TodayOff=OFFTIMES[Day]
TodayOff=sorted(TodayOff,key=lambda x:x.start)
scheduled.run(TodayOff)
